# 引入辅助函数
include(${CMAKE_SOURCE_DIR}/cmake/CMakeUtils.cmake)

# 依赖模块
get_all_subdirs(${CMAKE_SOURCE_DIR}/src/mod DEP_MODS)

# mod 依赖关系
set(AIS_DEPS "geom" "math" "alg")
set(ALG_DEPS "geom" "topo" "mesh" "math")
set(GEOM_DEPS "math")
set(GL_DEPS "geom" "ais" "alg" "math" "mesh")
set(MATH_DEPS)
set(MESH_DEPS "geom" "topo" "math")
set(PAINTER_DEPS "geom" "ais" "mesh" "math")
set(TOPO_DEPS)

foreach(dep ${DEP_MODS})
  add_subdirectory(mod/${dep})
endforeach()

# 立即渲染模式
get_all_subdirs(${CMAKE_SOURCE_DIR}/src/immediate IMM_DIRS)

foreach(dir ${IMM_DIRS})
  add_subdirectory(immediate/${dir})
  foreach(dep ${DEP_MODS})
    add_dependencies(${dir} ${dep})
  endforeach()
endforeach()

# 核心模式
get_all_subdirs(${CMAKE_SOURCE_DIR}/src/core CORE_DIRS)

foreach(dir ${CORE_DIRS})
  add_subdirectory(core/${dir})
  foreach(dep ${DEP_MODS})
    add_dependencies(${dir} ${dep})
  endforeach()
endforeach()

# 自定义渲染模式
get_all_subdirs(${CMAKE_SOURCE_DIR}/src/my MY_DIRS)

foreach(dir ${MY_DIRS})
  add_subdirectory(my/${dir})
  foreach(dep ${DEP_MODS})
    add_dependencies(${dir} ${dep})
  endforeach()
endforeach()

# 测试程序
add_subdirectory(test/gtest)
add_subdirectory(test/benchmark)

foreach(dep ${DEP_MODS})
  add_dependencies(gtest ${dep})
  add_dependencies(benchmark ${dep})
endforeach()
